﻿using System;
using System.Collections.Generic;

namespace Actya.Core.Util
{
	public static class EnumerableExtensions
	{
		public static IEnumerable<T> SelectDeep<T>(
		this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)
		{
			foreach (T item in source)
			{
				yield return item;
				foreach (T subItem in SelectDeep(selector(item), selector))
				{
					yield return subItem;
				}
			}
		}
	}
}
